<template>
  <div class="body-wrapper">

    <!--    查询部分 -->
    <div class="search-box">
      <el-form :inline="true" class="demo-form-inline" size="mini">
        <el-form-item label="品牌名称">
          <el-input v-model="searchForm.brandName" placeholder="请输入品牌名称"></el-input>
        </el-form-item>
        <el-date-picker
            v-model="value2"
            size="mini"
            type="datetimerange"
            :picker-options="pickerOptions"
            value-format="yyyy-MM-dd HH:mm:ss"
            range-separator="至"
            @change="chooseTime"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            align="left">
        </el-date-picker>

        <el-form-item style="margin-left: 10px">
          <el-button type="primary" @click="searchPage">查询</el-button>
          <el-button type="warning" @click="resetSearchForm">重置</el-button>
        </el-form-item>
      </el-form>

    </div>
    <!--    操作部分 -->
    <div class="exec-box">
      <el-button v-has-perm="['base:brand:add']" size="mini" type="success" icon="el-icon-share"
                 @click="editDialog=true,formData={brandLogo:''}">新建
      </el-button>
      <el-button v-has-perm="['base:brand:update']" size="mini" type="warning" icon="el-icon-edit"
                 @click="findById(ids[0]),editDialog=true"
                 :disabled="ids.length!=1">修改
      </el-button>
      <el-button v-has-perm="['base:brand:delete']" size="mini" type="danger" icon="el-icon-delete"
                 @click="doBatchDelete" :disabled="ids.length==0">删除
      </el-button>
    </div>

    <!--    列表部分 -->
    <el-table
        :data="tableData"
        row-key="id"
        stripe
        ref="table"
        @selection-change="selectChange"
        style="width: 100%">
      <el-table-column
          type="selection"
          align="center"
          width="55">
      </el-table-column>
      <el-table-column
          prop="id"
          label="品牌Id"
          align="center"
      >
      </el-table-column>
      <el-table-column
          prop="brandName"
          align="center"
          label="品牌名称"
      >

      </el-table-column>
      <el-table-column
          prop="brandSite"
          align="center"
          label="品牌站点"
      >
        <template v-slot="obj">
          <a :href="obj.row.brandSite" target="_blank">{{ obj.row.brandName + '站点' }}</a>
        </template>
      </el-table-column>
      <el-table-column
          prop="brandDesc"
          align="center"
          label="品牌描述"
      >

      </el-table-column>

      <el-table-column
          align="center"
          label="品牌图标"
      >
        <template v-slot="obj">
          <img :src="obj.row.brandLogo" height="35px" width="100px" alt="">
        </template>

      </el-table-column>
      <el-table-column
          prop="address"
          align="center">
        <template v-slot="obj">
          <el-button v-has-perm="['base:brand:update']" size="mini" type="primary" icon="el-icon-edit"
                     style="margin-right: 10px"
                     @click="findById(obj.row.id),editDialog=true"></el-button>


          <el-popconfirm
              v-has-perm="['base:brand:delete']"
              confirm-button-text='好的'
              cancel-button-text='不用了'
              @confirm="batchDelete"
              @cancel="batchDeleteCancel"
              icon="el-icon-info"
              icon-color="red"
              title="这是一段内容确定删除吗？"
          >
            <el-button size="mini" type="danger" slot="reference" icon="el-icon-delete"
                       @click="itemBtnClick(obj.row)"></el-button>
          </el-popconfirm>


        </template>
      </el-table-column>
    </el-table>
    <!--    分页部分-->
    <div class="page-box">
      <el-pagination
          background
          :current-page="searchForm.currentPage"
          :page-size="searchForm.pageSize"
          @current-change="pageChangeHandler"
          layout="prev, pager, next"
          :total="total">
      </el-pagination>
    </div>

    <!--    弹框-->

    <el-dialog title="操作实体" :visible.sync="editDialog" width="32%">
      <!---->
      <el-form ref="form" :model="formData" :rules="formRules" label-width="80px" size="small">
        <el-form-item label="品牌名称" prop="brandName">
          <el-input v-model="formData.brandName"></el-input>
        </el-form-item>

        <el-form-item label="品牌站点" prop="brandSite">
          <el-input v-model="formData.brandSite"></el-input>
        </el-form-item>
        <el-form-item label="品牌描述" prop="brandDesc">
          <el-input v-model="formData.brandDesc"></el-input>
        </el-form-item>

        <el-form-item label="品牌图标">
          <el-upload
              class="avatar-uploader"
              action=""
              accept="image/*"
              :show-file-list="false"
              :http-request="getImgBaseStr"
          >
            <img v-if="formData.brandLogo" :src="formData.brandLogo" class="avatar">
            <i v-else class="el-icon-plus avatar-uploader-icon"></i>
          </el-upload>
        </el-form-item>


      </el-form>


      <div slot="footer" class="dialog-footer">
        <el-button @click="editDialog = false" size="mini">取 消</el-button>
        <el-button type="primary" size="mini" @click="addOrEdit">确 定</el-button>
      </div>
    </el-dialog>


  </div>
</template>

<script src="./index.js">
</script>

<style src="./index.scss" lang="scss">

</style>
